<template>
  <div class="phyExamination">
    <phy-examination-options @search="search" ref="phyOptions"/>
    <phy-examination-table :loading="loading" @search="search" :data="data"/>
    <div class="demonstration-box">
        <!-- <span class="demonstration">显示总数</span> -->
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page.sync="currentPage"
          :page-size="pageParams.size"
          layout="total, prev, pager, next"
          :total="pageParams.totalCount"
        ></el-pagination>
      </div>
  </div>
</template>

<script>
import PhyExaminationOptions from './controls/phyExaminationOptions'
import PhyExaminationTable from './controls/phyExaminationTable'
import queryString from "querystring"
import page from 'data/page'

export default {
  name: 'phyExamination',
  mixins: [page],
  data() {
    return {
      data:[], //table数据
      currentPage: 1,
      loading: false
    }
  },
  components: {
    PhyExaminationOptions,
    PhyExaminationTable
  },
  mounted(){
    this.search();
  },
  methods:{
    search(){  //搜索
      this.loading = true;
      const optionParams = this.$refs.phyOptions.getData();
      const tableParams = {
        size: 20,
        page: this.currentPage -1
      };
      let params = this.lodash.assign({}, optionParams, tableParams);
      const param = queryString.stringify(params || {});
      this.api.get(`/physical?${param}`).then((res)=>{
        this.loading = false;
        if(!res.data) return;
        this.data = res.data.list;
        this.setPage(res.data)
      }).catch((err) => {
        console.log(err)
        this.$message(err.message)
      })
    }
  },
  watch: {
    currentPage() {
      this.search()
    }
  }
}
</script>
 
<style lang="less" scoped>

</style>
 